<?php
class Default_Model_left extends Zend_Db_Table
{
	public function get_category_solution()
	{ 
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('category_solution', array('id','title','images','introtext')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('featured= ?','1');
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function get_product_solution($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('article_solution', array('id','title','images')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('cat_id = ?',$id)
		          ->order('id DESC')
		          ->limit('4','0');		         
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function get_child($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('menu', array('id','title','type','keyt_id')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('parents 	 = ?',$id);
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function get_detail_solution($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('article_solution', array('id','title','introtext','fulltext')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('id 	 = ?',$id);
		$result = $db->fetchAll($select);
	    return $result;     
	}	
	
	public function get_title_solution($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('category_solution', array('id','title')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('id 	 = ?',$id);
		$result = $db->fetchAll($select);
	    return $result;     
	}	
	
	public function get_product_relate_solution($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		             ->from(array('st' => 'solution_product'))
                     ->join(array('dt' => 'details_product'),'st.product = dt.id', array('dt.title','dt.images','dt.introtext'))
		             ->where('st.solution = ?',$id);
		$result = $db->fetchAll($select);
	    return $result;     
	}	
}